package logic_setting_role

import (
	v1 "Sailor/app/Sailor-console-server/api/api_setting_role/v1"
	"Sailor/app/Sailor-console-server/internal/dao"
	"Sailor/app/Sailor-console-server/internal/model/do"
	"context"
	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
)

func (s *sSettingRole) LogicSettingRoleUpdate(ctx context.Context, req *v1.SettingRoleUpdateReq) (res *v1.SettingRoleUpdateRes, err error) {

	_, err = dao.SysRole.Ctx(ctx).Where(dao.SysRole.Columns().Uuid, req.Uuid).Update(do.SysRole{
		RoleName:   req.RoleName,
		RoleCode:   req.RoleCode,
		RoleNotes:  req.RoleNotes,
		RoleStatus: req.RoleStatus,
		RoleSort:   req.RoleSort,
	})
	if err != nil {
		g.Log().Error(ctx, err)
		return nil, gerror.New("更新失败")
	}

	return &v1.SettingRoleUpdateRes{}, nil
}
